package com.wondedDream.controller.web;

import com.wondedDream.model.UserMockExamRecord;
import com.wondedDream.service.UserMockExamRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController(value = "webUserMockExamRecordController")
@RequestMapping("/web/userMockExamRecords")
@Api(description = "客户端-用户模考记录模块")
public class UserMockExamRecordController {
    @Autowired
    private UserMockExamRecordService userMockExamRecordService;

    // 开始答题调用-保存用户模考记录
    @PostMapping("/saveUserMockExamRecord")
    @ApiOperation(value = "保存用户模考记录")
    public UserMockExamRecord saveUserMockExamRecord(@RequestBody UserMockExamRecord record) {
        return userMockExamRecordService.saveUserMockExamRecord(record);
    }

    // 根据记录 ID 获取用户模考记录
    @GetMapping("/{recordId}")
    @ApiOperation(value = "根据记录 ID 获取用户模考记录")
    public UserMockExamRecord getUserMockExamRecord(@PathVariable Integer recordId) {
        return userMockExamRecordService.getUserMockExamRecordById(recordId);
    }


    // 更新用户模考记录
    @PutMapping("/updateUserMockExamRecord/{recordId}")
    @ApiOperation(value = "更新用户模考记录")
    public UserMockExamRecord updateUserMockExamRecord(@PathVariable Integer recordId, @RequestBody UserMockExamRecord record) {
        record.setId(recordId);
        return userMockExamRecordService.updateUserMockExamRecord(record);
    }
}